import React, { Component } from 'react'

export default class LifeCycle extends Component {
  componentDidMount(){
    //定义器的触发
    this.timer=window.setInterval(()=>{
        console.log('-------定时器------------');
    },1000)
    document.querySelector("#btn").addEventListener('click',function(){

    })
  }
  componentWillUnmount(){
    clearInterval(this.timer)
    document.querySelector("#btn").removeEventListener('click')
  }
  render() {
    return (
      <div>
         <button id='btn'>按钮</button>
      </div>
    )
  }
}
